# _*_ coding: utf-8 _*_
# @Time : 2024-01-20 18:12
# @Author : wf
import time

from selenium import webdriver
from selenium.webdriver.common.by import By

options = webdriver.ChromeOptions()
options.binary_location = r'D:\Develop\Chrome\chrome104\Chrome-bin\chrome.exe'
options.add_experimental_option('detach', True)
options.add_experimental_option("excludeSwitches", ["enable-automation"])  # 禁止控制提示

options.add_argument('--start-maximized')  # 设置窗口最大化

service = webdriver.ChromeService()
service.path = r'D:\Develop\Chrome\chrome104\Chrome-bin\chromedriver.exe'

driver = webdriver.Chrome(options=options, service=service)
# driver.get('https://www.jd.com/')
driver.get('https://www.baidu.com')

time.sleep(2)
driver.find_element(By.NAME, 'wd').send_keys('我的世界\n')
time.sleep(2)

js_bottom = 'document.documentElement.scrollTop=100000'
# js_bottom = 'var q=document.body.scrollTop=100000'
# js_bottom = "window.scrollTo(0,document.body.scrollHeight)"
# time.sleep(3)
driver.execute_script(js_bottom)

time.sleep(2)
next = driver.find_element(By.XPATH, '//a[@class="n"]')
next.click()

time.sleep(2)
driver.back()

time.sleep(2)
driver.forward()

time.sleep(30)
# 退出
driver.quit()
